package com.itheima.Demo01.demo01;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateTest05 {
    public static void main(String[] args) {
        method();
        String time = "2020年12月12日 13:14:15";
        System.out.println("-----------");
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        LocalDateTime parse = LocalDateTime.parse(time,dateTimeFormatter);
        int dayOfYear = parse.getYear();
        System.out.println(dayOfYear);



    }

    private static void method() {
        LocalDateTime of = LocalDateTime.of(2020, 12, 12, 13, 14, 15);
        LocalDateTime localDateTime = of.plusYears(12);
        System.out.println(localDateTime);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        String s = of.format(dateTimeFormatter);
        System.out.println(s);
    }
}
